package com.onlinelibrary.controller;

import com.onlinelibrary.pojo.Borrow;
import com.onlinelibrary.result.Result;
import com.onlinelibrary.service.BorrowService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequiredArgsConstructor
@RestController
@RequestMapping("/borrow")
public class BorrowController {

    private final BorrowService borrowService;

    @PostMapping("/createBorrow")
    Result createBorrow(@RequestBody Borrow borrow) {
        System.out.println(borrow);
        return borrowService.createBorrow(borrow);
    }

    @PostMapping("/getBorrows")
    Result getBorrows(@RequestBody Borrow borrow) {
        return borrowService.getBorrows(borrow);
    }

    @PostMapping("/getAllBorrows")
    Result getAllBorrows(@RequestBody Borrow borrow) {
        return borrowService.getAllBorrows(borrow);
    }

    //getAllHisBorrows
    @PostMapping("/getAllHisBorrows")
    Result getAllHisBorrows(@RequestBody Borrow borrow) {
        return borrowService.getAllHisBorrows(borrow);
    }

    // /checkOk
    @PostMapping("/checkOk")
    Result checkOk(@RequestBody Borrow borrow) {
        return borrowService.checkOk(borrow);
    }

    // returnBook
    @PostMapping("/returnBook")
    Result returnBook(@RequestBody Borrow borrow) {
        return borrowService.returnBook(borrow);
    }

    @PostMapping("/getHotBooks")
    Result getHotBooks() {
        return borrowService.getHotBooks();
    }
}
